The present invention relates to a method and system for generating program code, for example source code and text code describing the source code.
In the design and implementation phase of software programming it is possible to use code generators to facilitate generation of program code. For instance the XWindows graphic system, which is known in the UNIX environment, provides code generators that produce the necessary code for a user interface according to a set of specifications.
In general a code generator extracts information from an input file or specification file and produces an output file, e.g. a source file, that is understandable by a compiler. The compiler then is able to generate from this source file an executable of executable file of machine code. The code generator produces a very large part of the source code to be written. The remaining part, which mostly is the program""s logic, has to be written by hand.
Code generation by a way of a code, generator has many advantages. When for example there exists repetitive patterns in the code to be written which must be replicated many times, a code generator can greatly reduce the effort the programmer has to make by reducing the number of lines to be manually written. Another advantage of code generation is that the naming in the software program becomes consistent throughout the entire program. Also consistency between the source code and the corresponding documentation code or documentation text can be greatly improved. Because of the fact that a great part of the program lines to be written is written automatically, design and implementation changes can be implemented within very short time. Also the number of bugs in the produced software code can be reduced.
Prior art code :generators, hereafter named dedicated code generators, are dedicated to one single language. The input to the code generator is in this case a fully prescribed specification file which is a listing of distinctive features which are used to define the specific aspects of the program code to be generated, for example instances, message names, types, attributes, links etc. The code generator generates an output file, for example a source file. The coding rules for conversion of the input file are build into the code generator itself (i.e. hard coded). A code generator dedicated to two languages must have two sets of coding rules hardcoded. This means that the dedicated code generators are not flexible in that both the input language and the output language are fixed and the coding rules have to be hardcoded into the code generator.
The present invention however provides a code generator wherein the language of the specification of the program to be build and the resulting code language are flexibly chosen by specifying external sets of coding rules or guidelines. In this case the specification file can be of an arbitrary format. According to a separate language descriptor the specification file is converted into a input file to the code generator. According to external guidelines the input file is converted into one or more code files, for example a C++source code file, a HTML documentation file describing the source code or a Unix makefile.
The present invention therefore relates to a method for generating code for a software program comprising:
specifying one or more input files describing the functionality of the software program according to a prescribed input language;
supplying first and second guidelines to code generator means wherein first and second guidelines describe the first and second rules respectively for conversion of said one or more input files;
supplying the input files to code generator means, wherein the code generator means convert the input files according to the first guidelines into one or more first code files and according to the second guidelines into one or more second code files.
The invention also comprises a method comprising:
supplying first and second language descriptors to interpretation means;
supplying a specification file describing the functionality of the software program to the interpretation means; wherein the interpretation means convert the specification file according to the first language descriptor into a first input file and according to the second language into a second input file.
The present invention also comprises the method for generating code for a software program comprising:
supplying one or more specification files describing the functionality of the software program to interpreter means;
supplying first and second specification language descriptors to interpreter means;
converting by the interpretation means of the specification files according to the first language descriptor into a first input to code generator means and according to the second language descriptor into a second input to code generator means;
supplying first and second guidelines to code generator means wherein first and second guidelines define the first and second rules respectively for conversion of the first and second input respectively;
converting the first input according to the first guidelines into one or more first code files and according to the second guidelines into one or more second code files
converting the second input according to the first guidelines into one or more third code files and according to the second guidelines into one or more fourth code files.
The present invention also relates to a drawing simulation tool of message passing in an object-oriented operating system. This drawing tool allows to describe Message Sequence Charts (or MSC) representing concurrent objects exchanging asynchronous messages.
The present invention also comprises the system which implements the methods mentioned above.